#include "algos.h"

//template for forward and reverse iterators
template<class si>
si inner_cut(si begin, si end, std::string const &symbols){
    while((begin != end)&&(symbols.find(*begin) != std::string::npos)){
        ++begin;
    }
    return begin;
}

void trim(std::string &where, std::string const &what){
    std::string::iterator	begin(inner_cut(where.begin(), where.end(), what));
    std::string::iterator	end(inner_cut(where.rbegin(), where.rend(), what).base());
    if(begin < end){
        where.assign(begin, end);
    }else{
        where.clear();
    }
}

void copyStream(std::istream &from, std::ostream &to){
    to << from.rdbuf();
}

